import Vue from 'vue'
import Router from 'vue-router'
import store from '../store'

Vue.use(Router)

/* Layout */
import Layout from '../page/layout/Layout'

 const constantRouterMap =  [
  {
    path: 'login',
    name: 'login',
    component: require('@/page/login').default
  },
  {
    path: '/admin',
    component: Layout,
    redirect: '/admin/home',
    children: [{
      path: 'home',
      name: 'home',
      component: resolve => require(['@/page/home'],resolve),
    }]
  },
  {
    path: '/setting',
    component: Layout,
    name: 'setting',
    children: [{
      path: 'settingPhotovoltaic',
      name: 'settingPhotovoltaic',
      component: resolve => require(['@/page/settingPhotovoltaic'],resolve),
      meta:{
        keepAlive:true
      }
    }, {
      path: 'settingBracket',
      name: 'settingBracket',
      component: resolve => require(['@/page/settingBracket'], resolve),
      meta: {
        keepAlive: true
      }
    }, {
        path: 'settingAnalysis',
        name: 'settingAnalysis',
        component: resolve => require(['@/page/settingAnalysis'], resolve),
        meta: {
            keepAlive: true
        }
    }]
  },

  {
    path: '*',
    redirect: '/admin/home'
  }
];

let newRoutes = constantRouterMap;




export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})

